package com.ler.yrmall.order.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.ler.yrmall.basic.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author leron
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oms_order_return_apply")
public class OrderReturnApplyEntity extends BaseEntity<OrderReturnApplyEntity> {

    /**
     * order_id
     */
    private Long orderId;

    /**
     * 子订单id
     */
    private Long itemId;

    /**
     * 退货商品id
     */
    private Long skuId;

    /**
     * 订单编号
     */
    private String orderSn;

    /**
     * 会员用户名
     */
    private String memberUsername;

    /**
     * 退款金额
     */
    private BigDecimal returnAmount;

    /**
     * 退货人姓名
     */
    private String returnName;

    /**
     * 退货人电话
     */
    private String returnPhone;

    /**
     * @see ReturnStatus
     */
    private Integer status;

    /**
     * 处理时间
     */
    private LocalDateTime handleTime;

    /**
     * 商品图片
     */
    private String skuImg;

    /**
     * 商品名称
     */
    private String skuName;

    /**
     * 商品销售属性
     */
    private String skuAttrsVals;

    /**
     * 退货数量
     */
    private Integer refundCount;

    /**
     * 商品单价
     */
    private BigDecimal skuPrice;

    /**
     * 商品实际支付单价
     */
    private BigDecimal skuRealPrice;

    /**
     * 退货原因
     */
    private String reason;


    /**
     * 收货人
     */
    private String receiveMan;

    /**
     * 收货时间
     */
    private LocalDateTime receiveTime;

    /**
     * 收货备注
     */
    private String receiveNote;

    /**
     * 收货电话
     */
    private String receivePhone;

    /**
     * 公司收货地址
     */
    private String companyAddress;

    public enum ReturnStatus {

        /**
         * 订单状态
         */
        PENDING(0,"待付款"),

        PROCESSED(1,"退货中"),

        FINISH(2,"一碗层"),

        REJECT(3,"已拒绝");

        private final Integer code;

        private final String dict;

        ReturnStatus(Integer code, String dict) {
            this.code = code;
            this.dict = dict;
        }

        public Integer getCode() {
            return code;
        }

        public String getDict() {
            return dict;
        }

        public static String translate(Integer code) {
            for (OrderReturnApplyEntity.ReturnStatus value : OrderReturnApplyEntity.ReturnStatus.values()) {
                if (value.getCode().equals(code)) {
                    return value.getDict();
                }
            }
            return "";
        }
    }

}
